<?php
namespace app\common\service;

use app\admin\model\Article;
use think\facade\Request;
use app\admin\traits\Result;
use think\Db;
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2022/7/13
 * Time: 17:29
 */
class ArticleService
{

    public static function taglib_article_list($param){
        $field = $param['field'];
        $cid = $param['cid'];
        $limit = $param['limit'];
        $order = $param['order'];
        $is_home = $param['is_home'];
        if($is_home == 1){
            $result = Article::where('cate_id', 'in',$cid)->where('is_hide',0)->where('is_home',1)->field($field)->limit($limit)->order($order)->select();
        }else{
            $result = Article::where('cate_id', 'in',$cid)->where('is_hide',0)->field($field)->limit($limit)->order($order)->select();
        }
        return $result;

    }

    public static function cate_tree_two(){
        $cate_list = Db::name('cate')->field('id,title')->where('parent_id',0)->order('sort asc,id asc')->select();
        foreach ($cate_list as $key => $val) {
        $cate_list[$key]['sub'] = Db::name('cate')->field('id,title')->where('parent_id',$val['id'])->order('sort asc,id asc')->select();
        }

        return $cate_list;

    }

    public static function cate_tree($info,$cid){
        $list = cate_tree_by_cid($info,$cid);
        return $list;
    }

}